﻿using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class Class1
    {
        private static double distance(Vector3 pp1, Vector2 pp2)
        {
            double dist;
            dist = Math.Sqrt(Math.Pow((pp2.X - pp1.X), 2) + Math.Pow((pp2.Y - pp1.Y), 2));
            return dist;
        }
        private static double distance1(Vector2 pp1, Vector2 pp2)
        {
            double dist;
            dist = Math.Sqrt(Math.Pow((pp2.X - pp1.X), 2) + Math.Pow((pp2.Y - pp1.Y), 2));
            return dist;
        }
        private static void dimrot(DxfDocument dxf1, Vector2 fp1, Vector2 fp2, double ang, double offset, String text, String toh, String tol)
        {
            Vector2 fp1p = fp1;
            Vector2 fp2p = fp2;
            if (fp2.Y > fp1.Y) { fp1 = fp2p; fp2 = fp1p; }

            double pi = 3.1415926535897;
            //       if (text.Contains("φ")) text = text+"  ";

            /*            double ang1,angp;
                        if (fp2.X == fp1.X)
                        {
                            if (fp2.Y > fp1.Y) ang1 = 90;
                            else ang1 = -90;
                        }
                        else
                        {
                            ang1=Math.Atan((fp2.Y-fp1.Y)/(fp2.X-fp1.X))*180/pi;
                        }
                        ang1=Math.Abs(ang1);
                        if (fp2.Y > fp1.Y) angp = 90 - ang - (90 - ang1);
                        else angp = 90 + ang - (90 - ang1);*/
            Vector2 fpp = new Vector2((fp1.X + fp2.X) / 2.0, (fp1.Y + fp2.Y) / 2.0);
            double ang1 = 0, ang2 = 0, ang3 = 0;
            if (ang > -90 && ang <= 90)
            {
                ang1 = ang; ang2 = 90 + ang; ang3 = ang2;
            }
            if (ang >= -180 && ang <= -90)
            {
                ang1 = 180 + ang; ang2 = 90 + ang; ang3 = ang2 + 180;
            }
            if (ang > 90 && ang <= 180)
            {
                ang1 = ang - 180; ang2 = ang - 270; ang3 = ang2 + 180;
            }
            Vector2 fp7p = new Vector2(fpp.X + offset * Math.Cos(ang2 * pi / 180), fpp.Y + offset * Math.Sin(ang2 * pi / 180));

            double xx = (fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X - fp1.Y + Math.Tan(ang2 * pi / 180) * fp1.X) / (Math.Tan(ang2 * pi / 180) - Math.Tan(ang1 * pi / 180));
            double yy = Math.Tan(ang1 * pi / 180) * xx + fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X;
            if (ang1 == 90.0 || ang1 == -90.0)
            {
                xx = fp7p.X;
                yy = fp1.Y;
            }
            Vector2 fp3 = new Vector2(xx, yy);

            double xx1 = (fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X - fp2.Y + Math.Tan(ang2 * pi / 180) * fp2.X) / (Math.Tan(ang2 * pi / 180) - Math.Tan(ang1 * pi / 180));
            double yy1 = Math.Tan(ang1 * pi / 180) * xx1 + fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X;
            if (ang1 == 90.0 || ang1 == -90.0)
            {
                xx1 = fp7p.X;
                yy1 = fp2.Y;
            }

            Vector2 fp4 = new Vector2(xx1, yy1);

            double lp3p4 = distance1(fp3, fp4);

            Vector2 fp5 = new Vector2(fp3.X + 2 * Math.Cos(ang2 * pi / 180), fp3.Y + 2 * Math.Sin(ang2 * pi / 180));
            Vector2 fp6 = new Vector2(fp4.X + 2 * Math.Cos(ang2 * pi / 180), fp4.Y + 2 * Math.Sin(ang2 * pi / 180));
            Vector2 fpl, fpr;
            fpl = fp3; fpr = fp4;

            if (ang >= 0 && ang <= 90)
            {
                if (fp3.X < fp4.X || fp3.Y < fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang > -90 && ang < 0)
            {
                if (fp3.X < fp4.X || fp3.Y > fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang > 90 && ang <= 180)
            {
                if (fp3.X < fp4.X || fp3.Y > fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang >= -180 && ang <= -90)
            {
                if (fp3.X < fp4.X || fp3.Y < fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }

            Vector2 fp7pp = new Vector2(fpl.X + 2.5 / distance1(fp3, fp4) * (fpl.X - fpr.X), fpl.Y + 2.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp7 = new Vector2(fp7pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp7pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp8 = new Vector2(fp7pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp7pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp9pp = new Vector2(fpl.X + 2.5 / distance1(fpr, fpl) * (fpr.X - fpl.X), fpl.Y + 2.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp9 = new Vector2(fp9pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp9pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp10 = new Vector2(fp9pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp9pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp11pp = new Vector2(fpr.X + 2.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fpr.Y + 2.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp11 = new Vector2(fp11pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp11pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp12 = new Vector2(fp11pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp11pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp13pp = new Vector2(fpr.X + 2.5 / distance1(fpl, fpr) * (fpl.X - fpr.X), fpr.Y + 2.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp13 = new Vector2(fp13pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp13pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp14 = new Vector2(fp13pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp13pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp15 = new Vector2(fpl.X + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpl.X - fpr.X),
                                       fpl.Y + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp16 = new Vector2(fpr.X + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpr.X - fpl.X),
                                       fpr.Y + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));

            double jl, angtext;
            //           if (ang > -90 && ang <= 90) jl = 2;
            //           else jl = -2;
            jl = 2;
            angtext = ang1;

            double sxl = 0.0;
            if (!text.Contains("(")) sxl = -4;

            double lentexttol = text.Length * 3.5 * 0.7 + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7;

            Vector2 fp18 = new Vector2(fp15.X + jl * Math.Cos(ang3 * pi / 180), fp15.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp21 = new Vector2(fp16.X + jl * Math.Cos(ang3 * pi / 180), fp16.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp21p = new Vector2(fp21.X - (Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 + sxl) * 0.5 * Math.Cos(ang1 * pi / 180), fp21.Y - (Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 + sxl) * 0.5 * Math.Sin(ang1 * pi / 180));
            Vector2 fp21pp = new Vector2(fp21p.X + (Math.Max(tol.Length, toh.Length) * 0.7 * 1.5 + 4) * 0.5 * Math.Cos(ang1 * pi / 180), fp21p.Y + (Math.Max(tol.Length, toh.Length) * 0.7 * 1.5 + 4) * 0.5 * Math.Sin(ang1 * pi / 180));

            Vector2 fp19 = new Vector2(fp18.X + (lentexttol + 6 + sxl) * 0.5 * Math.Cos(ang1 * pi / 180), fp18.Y + (lentexttol + 6 + sxl) * 0.5 * Math.Sin(ang1 * pi / 180));
            Vector2 fp19p = new Vector2(fp19.X + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 * Math.Cos(ang1 * pi / 180), fp19.Y + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 * Math.Sin(ang1 * pi / 180));
            Vector2 fp20 = new Vector2(fp21.X - (lentexttol - 4.5) * Math.Cos(ang1 * pi / 180), fp21.Y - (lentexttol - 4.5) * Math.Sin(ang1 * pi / 180));

            Vector2 fp17 = new Vector2(fp7p.X + jl * Math.Cos(ang3 * pi / 180), fp7p.Y + jl * Math.Sin(ang3 * pi / 180));


            Vector2 fp22 = new Vector2(fp17.X +
                lentexttol * 0.5 * 0.5 / distance1(fpl, fpr) * (fpl.X - fpr.X), fp17.Y + lentexttol * 0.5 * 0.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp23 = new Vector2(fp17.X + (lentexttol * 0.5 + 2 + sxl) * 0.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fp17.Y + (lentexttol * 0.5 + 2 + sxl) * 0.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp23p = new Vector2(fp17.X + (lentexttol - 1) * 0.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fp17.Y + (lentexttol - 1) * 0.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));

            Vector2 fp24 = new Vector2(fp19.X + jl * Math.Cos(ang3 * pi / 180), fp19.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp25 = new Vector2(fp23.X + jl * Math.Cos(ang3 * pi / 180), fp23.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp26 = new Vector2(fp21p.X + jl * Math.Cos(ang3 * pi / 180), fp21p.Y + jl * Math.Sin(ang3 * pi / 180));

            if (lentexttol < lp3p4)
            {
                Text text1 = new Text(text, fp22, 2, angtext);
                //                    zhc = "context.fillText(\"" + text + "\"," + fp22.X + "," + fp22.Y + ");";
                //                    sw.WriteLine(zhc);


                text1.WidthFactor = 0.7;
                Text text2 = new Text(tol, fp23, 1.5, angtext);
                //                    zhc = "context.fillText(\"" + tol + "\"," + fp23.X + "," + fp23.Y + ");";
                //                    sw.WriteLine(zhc);


                text2.WidthFactor = 0.7;
                Text text3 = new Text(toh, fp25, 1.5, angtext);
                //                    zhc = "context.fillText(\"" + toh + "\"," + fp25.X + "," + fp25.Y + ");";
                //                    sw.WriteLine(zhc);


                text3.WidthFactor = 0.7;
                dxf1.AddEntity(new EntityObject[] { text1, text2, text3 });
                if (text.Contains("("))
                {
                    Text text4 = new Text(")", fp23p, 3.5, angtext);
                    //                        zhc = "context.fillText(\"" + ")" + "\"," + fp23p.X + "," + fp23p.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text4.WidthFactor = 0.7;
                    dxf1.AddEntity(new EntityObject[] { text4 });
                }

                Solid sd1 = new Solid(fpl, fp9, fp10);

                Solid sd2 = new Solid(fpr, fp13, fp14);



                dxf1.AddEntity(new EntityObject[] { sd1, sd2 });
            }
            else
            {
                if (distance1(fpl, fp3) < 0.0001)
                {
                    Text text1 = new Text(text, fp18, 0.5, angtext);
                    //                       zhc = "context.fillText(\"" + text + "\"," + fp18.X + "," + fp18.Y + ");";
                    //                     sw.WriteLine(zhc);


                    text1.WidthFactor = 0.7;
                    Text text2 = new Text(tol, fp19, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + tol + "\"," + fp19.X + "," + fp19.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text2.WidthFactor = 0.7;
                    Text text3 = new Text(toh, fp24, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + toh + "\"," + fp24.X + "," + fp24.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text3.WidthFactor = 0.7;
                    Line linep = new Line(fpl, fp15);


                    Solid sd1 = new Solid(fpl, fp7, fp8);


                    Solid sd2 = new Solid(fpr, fp11, fp12);


                    Line linepp = new Line(fpr, new Vector2((fp16.X + fpr.X) / 2, (fp16.Y + fpr.Y) / 2));


                    dxf1.AddEntity(new EntityObject[] { text1, text2, text3, linep, /*sd1,*/ sd2, linepp });
                    if (text.Contains("("))
                    {
                        Text text4 = new Text(")", fp19p, 3.5, angtext);


                        text4.WidthFactor = 0.7;
                        dxf1.AddEntity(new EntityObject[] { text4 });
                    }

                }
                else
                {
                    Text text1 = new Text(text, fp20, 0.2, angtext);
                    //                       zhc = "context.fillText(\"" + text + "\"," + fp20.X + "," + fp20.Y + ");";
                    //                       sw.WriteLine(zhc);


                    text1.WidthFactor = 0.7;
                    Text text2 = new Text(tol, fp21p, 1.5, angtext);
                    //                       zhc = "context.fillText(\"" + tol + "\"," + fp21p.X + "," + fp21p.Y + ");";
                    //                       sw.WriteLine(zhc);


                    text2.WidthFactor = 0.7;
                    Text text3 = new Text(toh, fp26, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + toh + "\"," + fp26.X + "," + fp26.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text3.WidthFactor = 0.7;
                    Solid sd1 = new Solid(fpl, fp7, fp8);


                    Solid sd2 = new Solid(fpr, fp11, fp12);


                    Line linep = new Line(fpr, fp16);


                    Line linepp = new Line(fpl, new Vector2((fp15.X + fpl.X) / 2, (fp15.Y + fpl.Y) / 2));


                    dxf1.AddEntity(new EntityObject[] { text1, text2, text3/*, linep*/, linepp, sd1, sd2 });
                    if (text.Contains("("))
                    {
                        Text text4 = new Text(")", fp21pp, 3.5, angtext);
                        //                            zhc = "context.fillText(\"" + ")" + "\"," + fp21pp.X + "," + fp21pp.Y + ");";
                        //                            sw.WriteLine(zhc);


                        text4.WidthFactor = 0.7;
                        dxf1.AddEntity(new EntityObject[] { text4 });
                    }

                }
            }
            Line line1 = new Line(fp1, fp5);


            Line line2 = new Line(fp2, fp6);


            Line line3 = new Line(fp3, fp4);


            dxf1.AddEntity(new EntityObject[] { line1, line2, line3 });
        }
        private static void dimrot1(DxfDocument dxf1, Vector2 fp1, Vector2 fp2, double ang, double offset, String text, String toh, String tol)//(左下）
        {
            Vector2 fp1p = fp1;
            Vector2 fp2p = fp2;
            if (fp2.Y > fp1.Y) { fp1 = fp2p; fp2 = fp1p; }

            double pi = 3.1415926535897;
            //       if (text.Contains("φ")) text = text+"  ";

            /*            double ang1,angp;
                        if (fp2.X == fp1.X)
                        {
                            if (fp2.Y > fp1.Y) ang1 = 90;
                            else ang1 = -90;
                        }
                        else
                        {
                            ang1=Math.Atan((fp2.Y-fp1.Y)/(fp2.X-fp1.X))*180/pi;
                        }
                        ang1=Math.Abs(ang1);
                        if (fp2.Y > fp1.Y) angp = 90 - ang - (90 - ang1);
                        else angp = 90 + ang - (90 - ang1);*/
            Vector2 fpp = new Vector2((fp1.X + fp2.X) / 2.0, (fp1.Y + fp2.Y) / 2.0);
            double ang1 = 0, ang2 = 0, ang3 = 0;
            if (ang > -90 && ang <= 90)
            {
                ang1 = ang; ang2 = 90 + ang; ang3 = ang2;
            }
            if (ang >= -180 && ang <= -90)
            {
                ang1 = 180 + ang; ang2 = 90 + ang; ang3 = ang2 + 180;
            }
            if (ang > 90 && ang <= 180)
            {
                ang1 = ang - 180; ang2 = ang - 270; ang3 = ang2 + 180;
            }
            Vector2 fp7p = new Vector2(fpp.X + offset * Math.Cos(ang2 * pi / 180), fpp.Y + offset * Math.Sin(ang2 * pi / 180));

            double xx = (fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X - fp1.Y + Math.Tan(ang2 * pi / 180) * fp1.X) / (Math.Tan(ang2 * pi / 180) - Math.Tan(ang1 * pi / 180));
            double yy = Math.Tan(ang1 * pi / 180) * xx + fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X;
            if (ang1 == 90.0 || ang1 == -90.0)
            {
                xx = fp7p.X;
                yy = fp1.Y;
            }
            Vector2 fp3 = new Vector2(xx, yy);

            double xx1 = (fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X - fp2.Y + Math.Tan(ang2 * pi / 180) * fp2.X) / (Math.Tan(ang2 * pi / 180) - Math.Tan(ang1 * pi / 180));
            double yy1 = Math.Tan(ang1 * pi / 180) * xx1 + fp7p.Y - Math.Tan(ang1 * pi / 180) * fp7p.X;
            if (ang1 == 90.0 || ang1 == -90.0)
            {
                xx1 = fp7p.X;
                yy1 = fp2.Y;
            }

            Vector2 fp4 = new Vector2(xx1, yy1);

            double lp3p4 = distance1(fp3, fp4);

            Vector2 fp5 = new Vector2(fp3.X + 2 * Math.Cos(ang2 * pi / 180), fp3.Y + 2 * Math.Sin(ang2 * pi / 180));
            Vector2 fp6 = new Vector2(fp4.X + 2 * Math.Cos(ang2 * pi / 180), fp4.Y + 2 * Math.Sin(ang2 * pi / 180));
            Vector2 fpl, fpr;
            fpl = fp3; fpr = fp4;

            if (ang >= 0 && ang <= 90)
            {
                if (fp3.X < fp4.X || fp3.Y < fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang > -90 && ang < 0)
            {
                if (fp3.X < fp4.X || fp3.Y > fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang > 90 && ang <= 180)
            {
                if (fp3.X < fp4.X || fp3.Y > fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }
            if (ang >= -180 && ang <= -90)
            {
                if (fp3.X < fp4.X || fp3.Y < fp4.Y)
                {
                    fpl = fp3; fpr = fp4;
                }
                else
                {
                    fpl = fp4; fpr = fp3;
                }
            }

            Vector2 fp7pp = new Vector2(fpl.X + 2.5 / distance1(fp3, fp4) * (fpl.X - fpr.X), fpl.Y + 2.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp7 = new Vector2(fp7pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp7pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp8 = new Vector2(fp7pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp7pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp9pp = new Vector2(fpl.X + 2.5 / distance1(fpr, fpl) * (fpr.X - fpl.X), fpl.Y + 2.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp9 = new Vector2(fp9pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp9pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp10 = new Vector2(fp9pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp9pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp11pp = new Vector2(fpr.X + 2.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fpr.Y + 2.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp11 = new Vector2(fp11pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp11pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp12 = new Vector2(fp11pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp11pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp13pp = new Vector2(fpr.X + 2.5 / distance1(fpl, fpr) * (fpl.X - fpr.X), fpr.Y + 2.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp13 = new Vector2(fp13pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos(ang2 * pi / 180), fp13pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin(ang2 * pi / 180));
            Vector2 fp14 = new Vector2(fp13pp.X + 2.5 * Math.Tan(10 * pi / 180) * Math.Cos((ang2 + 180) * pi / 180), fp13pp.Y + 2.5 * Math.Tan(10 * pi / 180) * Math.Sin((ang2 + 180) * pi / 180));

            Vector2 fp15 = new Vector2(fpl.X + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpl.X - fpr.X),
                                       fpl.Y + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp16 = new Vector2(fpr.X + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpr.X - fpl.X),
                                       fpr.Y + (text.Length * 3.5 + Math.Max(tol.Length, toh.Length) * 1.5) * 0.7 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));

            double jl, angtext;
            //           if (ang > -90 && ang <= 90) jl = 2;
            //           else jl = -2;
            jl = 2;
            angtext = ang1;

            double sxl = 0.0;
            if (!text.Contains("(")) sxl = -4;

            double lentexttol = text.Length * 3.5 * 0.7 + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7;

            Vector2 fp18 = new Vector2(fp15.X + jl * Math.Cos(ang3 * pi / 180), fp15.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp21 = new Vector2(fp16.X + jl * Math.Cos(ang3 * pi / 180), fp16.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp21p = new Vector2(fp21.X - (Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 + sxl) * 0.5 * Math.Cos(ang1 * pi / 180), fp21.Y - (Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 + sxl) * 0.5 * Math.Sin(ang1 * pi / 180));
            Vector2 fp21pp = new Vector2(fp21p.X + (Math.Max(tol.Length, toh.Length) * 0.7 * 1.5 + 4) * 0.5 * Math.Cos(ang1 * pi / 180), fp21p.Y + (Math.Max(tol.Length, toh.Length) * 0.7 * 1.5 + 4) * 0.5 * Math.Sin(ang1 * pi / 180));

            Vector2 fp19 = new Vector2(fp18.X + (lentexttol + 6 + sxl) * 0.5 * Math.Cos(ang1 * pi / 180), fp18.Y + (lentexttol + 6 + sxl) * 0.5 * Math.Sin(ang1 * pi / 180));
            Vector2 fp19p = new Vector2(fp19.X + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 * Math.Cos(ang1 * pi / 180), fp19.Y + Math.Max(tol.Length, toh.Length) * 1.5 * 0.7 * Math.Sin(ang1 * pi / 180));
            Vector2 fp20 = new Vector2(fp21.X - (lentexttol - 4.5) * Math.Cos(ang1 * pi / 180), fp21.Y - (lentexttol - 4.5) * Math.Sin(ang1 * pi / 180));

            Vector2 fp17 = new Vector2(fp7p.X + jl * Math.Cos(ang3 * pi / 180), fp7p.Y + jl * Math.Sin(ang3 * pi / 180));


            Vector2 fp22 = new Vector2(fp17.X +
                lentexttol * 0.5 * 0.5 / distance1(fpl, fpr) * (fpl.X - fpr.X), fp17.Y + lentexttol * 0.5 * 0.5 / distance1(fpl, fpr) * (fpl.Y - fpr.Y));
            Vector2 fp23 = new Vector2(fp17.X + (lentexttol * 0.5 + 2 + sxl) * 0.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fp17.Y + (lentexttol * 0.5 + 2 + sxl) * 0.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));
            Vector2 fp23p = new Vector2(fp17.X + (lentexttol - 1) * 0.5 / distance1(fpl, fpr) * (fpr.X - fpl.X), fp17.Y + (lentexttol - 1) * 0.5 / distance1(fpl, fpr) * (fpr.Y - fpl.Y));

            Vector2 fp24 = new Vector2(fp19.X + jl * Math.Cos(ang3 * pi / 180), fp19.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp25 = new Vector2(fp23.X + jl * Math.Cos(ang3 * pi / 180), fp23.Y + jl * Math.Sin(ang3 * pi / 180));
            Vector2 fp26 = new Vector2(fp21p.X + jl * Math.Cos(ang3 * pi / 180), fp21p.Y + jl * Math.Sin(ang3 * pi / 180));

            if (lentexttol < lp3p4)
            {
                Text text1 = new Text(text, fp22, 0.5, angtext);
                //                    zhc = "context.fillText(\"" + text + "\"," + fp22.X + "," + fp22.Y + ");";
                //                    sw.WriteLine(zhc);


                text1.WidthFactor = 0.7;
                Text text2 = new Text(tol, fp23, 1.5, angtext);
                //                    zhc = "context.fillText(\"" + tol + "\"," + fp23.X + "," + fp23.Y + ");";
                //                    sw.WriteLine(zhc);


                text2.WidthFactor = 0.7;
                Text text3 = new Text(toh, fp25, 1.5, angtext);
                //                    zhc = "context.fillText(\"" + toh + "\"," + fp25.X + "," + fp25.Y + ");";
                //                    sw.WriteLine(zhc);


                text3.WidthFactor = 0.7;
                dxf1.AddEntity(new EntityObject[] { text1, text2, text3 });
                if (text.Contains("("))
                {
                    Text text4 = new Text(")", fp23p, 3.5, angtext);
                    //                        zhc = "context.fillText(\"" + ")" + "\"," + fp23p.X + "," + fp23p.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text4.WidthFactor = 0.7;
                    dxf1.AddEntity(new EntityObject[] { text4 });
                }

                Solid sd1 = new Solid(fpl, fp9, fp10);

                Solid sd2 = new Solid(fpr, fp13, fp14);



                dxf1.AddEntity(new EntityObject[] { /*sd1,*/ sd2 });
            }
            else
            {
                if (distance1(fpl, fp3) < 0.0001)
                {
                    Text text1 = new Text(text, fp18, 3.5, angtext);
                    //                       zhc = "context.fillText(\"" + text + "\"," + fp18.X + "," + fp18.Y + ");";
                    //                     sw.WriteLine(zhc);


                    text1.WidthFactor = 0.7;
                    Text text2 = new Text(tol, fp19, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + tol + "\"," + fp19.X + "," + fp19.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text2.WidthFactor = 0.7;
                    Text text3 = new Text(toh, fp24, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + toh + "\"," + fp24.X + "," + fp24.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text3.WidthFactor = 0.7;
                    Line linep = new Line(fpl, fp15);


                    Solid sd1 = new Solid(fpl, fp7, fp8);


                    Solid sd2 = new Solid(fpr, fp11, fp12);


                    Line linepp = new Line(fpr, new Vector2((fp16.X + fpr.X) / 2, (fp16.Y + fpr.Y) / 2));


                    dxf1.AddEntity(new EntityObject[] { text1, text2, text3, linep, /*sd1,*/ sd2, linepp });
                    if (text.Contains("("))
                    {
                        Text text4 = new Text(")", fp19p, 3.5, angtext);


                        text4.WidthFactor = 0.7;
                        dxf1.AddEntity(new EntityObject[] { text4 });
                    }

                }
                else
                {
                    Text text1 = new Text(text, fp20, 1, angtext);
                    //                       zhc = "context.fillText(\"" + text + "\"," + fp20.X + "," + fp20.Y + ");";
                    //                       sw.WriteLine(zhc);


                    text1.WidthFactor = 0.7;
                    Text text2 = new Text(tol, fp21p, 1.5, angtext);
                    //                       zhc = "context.fillText(\"" + tol + "\"," + fp21p.X + "," + fp21p.Y + ");";
                    //                       sw.WriteLine(zhc);


                    text2.WidthFactor = 0.7;
                    Text text3 = new Text(toh, fp26, 1.5, angtext);
                    //                        zhc = "context.fillText(\"" + toh + "\"," + fp26.X + "," + fp26.Y + ");";
                    //                        sw.WriteLine(zhc);


                    text3.WidthFactor = 0.7;
                    Solid sd1 = new Solid(fpl, fp7, fp8);


                    Solid sd2 = new Solid(fpr, fp11, fp12);


                    Line linep = new Line(fpr, fp16);


                    Line linepp = new Line(fpl, new Vector2((fp15.X + fpl.X) / 2, (fp15.Y + fpl.Y) / 2));


                    dxf1.AddEntity(new EntityObject[] { text1, text2, text3/*, linep*/, linepp, sd1, sd2 });
                    if (text.Contains("("))
                    {
                        Text text4 = new Text(")", fp21pp, 3.5, angtext);
                        //                            zhc = "context.fillText(\"" + ")" + "\"," + fp21pp.X + "," + fp21pp.Y + ");";
                        //                            sw.WriteLine(zhc);


                        text4.WidthFactor = 0.7;
                        dxf1.AddEntity(new EntityObject[] { text4 });
                    }

                }
            }
            Line line1 = new Line(fp1, fp5);


            Line line2 = new Line(fp2, fp6);


            Line line3 = new Line(fp3, fp4);


            dxf1.AddEntity(new EntityObject[] { line1,/*line2,*/ line3 });
        }

        public static void Standard20326_1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double L = 108;
            double l = 24;
            double l2 = 11;
            double l3 = 39;
            double d = 10;
            double d1 = 10;
            double d2 = 7.5;
            double a = 8;

            //坐标
            Vector2 v0 = new Vector2(0, 0);
            Vector2 v1 = new Vector2(v0.X + 0.5 * d, v0.Y);
            Vector2 v2 = new Vector2(v1.X, v1.Y + 0.4 * d );
            Vector2 v3 = new Vector2(v1.X + 0.2 * l, v1.Y + d / 2);
            Vector2 v4 = new Vector2(v1.X + l, v1.Y + d / 2);
            Vector2 v5 = new Vector2(v4.X, v2.Y);
            Vector2 v6 = new Vector2(v4.X, v1.Y + d2 / 2);
            Vector2 v7 = fun.Polar(v6, 0, (l3 - l) * 2 / 3);
            Vector2 v8 = new Vector2(v6.X + l3 - l, v1.Y + d1 / 2);
            Vector2 v9 = new Vector2(v1.X + L, v8.Y);
            Vector2 v10 = fun.Polar(v9, -90 * pi / 180, d1 * 4.5 / 10);
            Vector2 v11 = fun.Polar(v10, 180 * pi / 180, l2);
            Vector2 v12 = new Vector2(v11.X, v9.Y);
            Vector2 v13 = fun.Polar(v10, 180 * pi / 180, 1);
            Vector2 v14 = new Vector2(v9.X + 0.5 * d, v0.Y);
            Vector2 v15 = new Vector2(v2.X, -v2.Y);
            Vector2 v16 = new Vector2(v3.X, -v3.Y);
            Vector2 v17 = new Vector2(v4.X, -v4.Y);
            Vector2 v18 = new Vector2(v5.X, -v5.Y);
            Vector2 v19 = new Vector2(v6.X, -v6.Y);
            Vector2 v20 = new Vector2(v7.X, -v7.Y);
            Vector2 v21 = new Vector2(v8.X, -v8.Y);
            Vector2 v22 = new Vector2(v9.X, -v9.Y);
            Vector2 v23 = new Vector2(v10.X, -v10.Y);
            Vector2 v24 = new Vector2(v11.X, -v11.Y);
            Vector2 v25 = new Vector2(v12.X, -v12.Y);
            Vector2 v26 = new Vector2(v13.X, -v13.Y);
            Vector2 v27 = new Vector2(v0.X - 8, v0.Y);
            Vector2 v28 = new Vector2(v14.X + 8, v0.Y);
            Vector2 v29 = fun.Polar(v28, 0, 30);
            Vector2 v30 = fun.Polar(v29, pi, 5);
            Vector2 v31 = fun.Polar(v30, 90 * pi / 180, 0.6569);
            Vector2 v32 = fun.Polar(v30, -90 * pi / 180, 0.6569);
            Vector2 v33 = fun.Polar(v29, 90 * pi / 180, 5);
            Vector2 v34 = fun.Polar(v33, pi, 0.6569);
            Vector2 v35 = fun.Polar(v33, 0, 0.6569);
            Vector2 v36 = fun.Polar(v29, 0, 5);
            Vector2 v37 = fun.Polar(v36, 90 * pi / 180, 0.6569);
            Vector2 v38 = fun.Polar(v36, -90 * pi / 180, 0.6569);
            Vector2 v39 = fun.Polar(v29, -90 * pi / 180, 5);
            Vector2 v40 = fun.Polar(v39, pi, 0.6569);
            Vector2 v41 = fun.Polar(v39, 0, 0.6569);
            Vector2 v42 = fun.Polar(v30, pi, 8);
            Vector2 v43 = fun.Polar(v33, 90*pi/180, 8);
            Vector2 v44 = fun.Polar(v36, 0, 8);
            Vector2 v45 = fun.Polar(v39, -90*pi/180, 8);

            LwPolyline line1 = new LwPolyline();
            line1.Vertexes.Add(new LwPolylineVertex(v2));
            line1.Vertexes.Add(new LwPolylineVertex(v3));
            line1.Vertexes.Add(new LwPolylineVertex(v4));
            line1.Vertexes.Add(new LwPolylineVertex(v6));
            line1.Vertexes.Add(new LwPolylineVertex(v7));
            line1.Vertexes.Add(new LwPolylineVertex(v8));
            line1.Vertexes.Add(new LwPolylineVertex(v9));
            line1.Vertexes.Add(new LwPolylineVertex(v22));
            line1.Vertexes.Add(new LwPolylineVertex(v21));
            line1.Vertexes.Add(new LwPolylineVertex(v20));
            line1.Vertexes.Add(new LwPolylineVertex(v19));
            line1.Vertexes.Add(new LwPolylineVertex(v17));
            line1.Vertexes.Add(new LwPolylineVertex(v16));
            line1.Vertexes.Add(new LwPolylineVertex(v15));
            line1.Vertexes.Add(new LwPolylineVertex(v2));
            line1.Layer = contour;
            line1.Lineweight = Lineweight.W50;
            dxf.AddEntity(line1);
            Line line2 = new Line(v2, v5);
            line2.Layer = contour;
            line2.Lineweight = Lineweight.W50;
            dxf.AddEntity(line2);
            Line line3 = new Line(v3, v16);
            line3.Layer = contour;
            line3.Lineweight = Lineweight.W50;
            dxf.AddEntity(line3);
            Line line4 = new Line(v7, v20);
            line4.Layer = contour;
            line4.Lineweight = Lineweight.W50;
            dxf.AddEntity(line4);
            Line line5 = new Line(v8, v21);
            line5.Layer = contour;
            line5.Lineweight = Lineweight.W50;
            dxf.AddEntity(line5);
            Line line6 = new Line(v12, v11);
            line6.Layer = contour;
            line6.Lineweight = Lineweight.W50;
            dxf.AddEntity(line6);
            Line line7 = new Line(v11, v10);
            line7.Layer = contour;
            line7.Lineweight = Lineweight.W50;
            dxf.AddEntity(line7);
            Line line8 = new Line(v24, v25);
            line8.Layer = contour;
            line8.Lineweight = Lineweight.W50;
            dxf.AddEntity(line8);
            Line line9 = new Line(v24, v23);
            line9.Layer = contour;
            line9.Lineweight = Lineweight.W50;
            dxf.AddEntity(line9);
            Line line10 = new Line(v13, v26);
            line10.Layer = contour;
            line10.Lineweight = Lineweight.W50;
            dxf.AddEntity(line10);
            LwPolyline line11 = new LwPolyline();
            line11.Vertexes.Add(new LwPolylineVertex(v31));
            line11.Vertexes.Add(new LwPolylineVertex(v34));
            line11.Vertexes.Add(new LwPolylineVertex(v35));
            line11.Vertexes.Add(new LwPolylineVertex(v37));
            line11.Vertexes.Add(new LwPolylineVertex(v38));
            line11.Vertexes.Add(new LwPolylineVertex(v41));
            line11.Vertexes.Add(new LwPolylineVertex(v40));
            line11.Vertexes.Add(new LwPolylineVertex(v32));
            line11.Vertexes.Add(new LwPolylineVertex(v31));
            line11.Layer = contour;
            line11.Lineweight = Lineweight.W50;
            dxf.AddEntity(line11);
            Line line12 = new Line(v12, v10);
            line12.Lineweight = Lineweight.W25;
            line12.Layer = additionalline;
            dxf.AddEntity(line12); 
            Line line13 = new Line(v11, v9);
            line13.Lineweight = Lineweight.W25;
            line13.Layer = additionalline;
            dxf.AddEntity(line13);
            Line line14 = new Line(v24, v22);
            line14.Lineweight = Lineweight.W25;
            line14.Layer = additionalline;
            dxf.AddEntity(line14);
            Line line15 = new Line(v25, v23);
            line15.Lineweight = Lineweight.W25;
            line15.Layer = additionalline;
            dxf.AddEntity(line15);
            Line line16 = new Line(v9, v14);
            line16.Lineweight = Lineweight.W25;
            line16.Layer = additionalline;
            dxf.AddEntity(line16);
            Line line17 = new Line(v22, v14);
            line17.Lineweight = Lineweight.W25;
            line17.Layer = additionalline;
            dxf.AddEntity(line17);
            Line line18 = new Line(v0, v2);
            line18.Lineweight = Lineweight.W25;
            line18.Layer = additionalline;
            dxf.AddEntity(line18);
            Line line19 = new Line(v0, v15);
            line19.Lineweight = Lineweight.W25;
            line19.Layer = additionalline;
            dxf.AddEntity(line19);
            Line line20 = new Line(v27, v28);
            line20.Layer = centre;
            line20.Lineweight = Lineweight.W25;
            line20.Linetype = Linetype.DashDot;
            dxf.AddEntity(line20);
            Line line21 = new Line(v42, v44);
            line21.Layer = centre;
            line21.Lineweight = Lineweight.W25;
            line21.Linetype = Linetype.DashDot;
            dxf.AddEntity(line21);
            Line line22 = new Line(v43, v45);
            line22.Layer = centre;
            line22.Lineweight = Lineweight.W25;
            line22.Linetype = Linetype.DashDot;
            dxf.AddEntity(line22);
            Line line23 = new Line(v15, v18);
            line23.Layer = contour;
            line23.Lineweight = Lineweight.W50;
            dxf.AddEntity(line23);

            dimrot(dxf, v3, v16, 90, 25, "d", "", "");
            dimrot(dxf, v7, v20, 90, 2, "d2", "", "");
            dimrot(dxf, v12, v25, 90, 25, "d1", "", "");
            dimrot(dxf, v15, v17, 180, 15, "l", "", "");
            dimrot(dxf, v15, v21, 180, 25, "l3", "", "");
            dimrot(dxf, v15, v22, 180, 30, "L", "", "");
            dimrot(dxf, v25, v22, 180, 15, "l2", "", "");
            dimrot(dxf, v40, v37, -135, 20, "□a", "", "");


            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v34));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v35));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v38));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v32));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

    }
}
